<template>
  <div>
    <div class="detail-container page-container">
      <div class="top">
        <div class="border"></div>
        <div class="title">Batch Search Result</div>
        <!-- <div class="name item">
          name:
          <span class="content"
            >"Pesticides in Groundwater, Suffolk County NY"</span
          >
        </div> -->
        <div class="name item">
          Description :
          <span class="content"
            >{{description}}</span
          >
        </div>
        <!-- <div class="name item">
          Source:
          <span class="content">"Chemicals+Assays"</span>
        </div> -->
        <div class="name item">
          Number of Generic Chemicals:
          <span class="content">{{total}}</span>
        </div>
      </div>
      <div class="bottom flex-between">
        <div
          class="son"
          v-for="(item, index) in batchTableData.list"
          :key="index"
          @click="goToDetail(item)"
        >
          <div class="img"></div>
          <div class="name">
            <div class="tit">{{ item.punchem_cid }}</div>
            <div class="time">{{ item.molecular_formula }}</div>
          </div>
        </div>
        <p v-if="batchTableData.list.length == 0" class="no-data" style="margin: 20px 0;color: #999;width:100%;text-align:center;">NoData</p>
        <Pagination
          :pageNo="pageNo"
          :total="batchTableData.total"
          :pageSize="pageSize"
          @handleCurrentChange="handleCurrentChange"
        />
      </div>
      <div class="more-tips-box">
        <div class="more-tips">
          <i class="el-icon-warning-outline"></i>
          <div class="more-tips-content">
            <p class="tit">Maybe you want to find below datasets</p>
            <p class="content">
              <span>Heapatotoxicity</span> has 60% similarity…
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
import Pagination from "@/components/Pagination.vue";
export default {
  components: {
    Pagination,
  },
  computed: {
    ...mapState({
      isPhone: (state) => state.isPhone,
      batchTableData: (state) => state.batchTableData,
    }),
  },
  data() {
    return {
      pageNo: 1, // 分页
      total: 0,
      pageSize: 10,
      description: "",
    };
  },
  created() {
    // this.getList({
    //   name: this.$route.query.gene,
    //   type: this.$route.query.type,
    // });

    //   描述字段 用户输入（data from user inputation）或者文件上传(File upload)
    if (this.$store.state.batchSearchForm) {
      this.description = "File upload";
    } else {
      this.description = "data from user inputation";
    }
  },
  methods: {
    goToDetail(item) {
      this.$router.push({ path: "/searchCompoundResult" , query: {
        id: item.taid
      }});
    },
    getList({ name, type }) {
      this.$api
        .batchSearchCategoryInfo({
          name,
          pageSize: this.pageSize,
          pageNo: this.pageNo,
          type,
        })
        .then((res) => {
          this.total = res.total;
          this.list = res.list;
          if (this.pageNo == 1) {
            this.bestMatch = res.list[0];
          }
        });
    },
    handleCurrentChange(data) {
      this.pageNo = data;
      this.$store.dispatch("handleBatchSearch", this.pageNo, this.pageSize);
    },
  },
};
</script>

<style lang="scss" scoped>
.page-container {
  margin: 0 auto;
  margin-top: 24px;
  width: 1340px;
  .top {
    position: relative;
    // padding-left: 10px;
    background: linear-gradient(331deg, #f9f6ff 0%, #ffffff 100%);
    border-radius: 2px 2px 0px 0px;
    padding-bottom: 30px;
    &::after {
      content: "";
      position: absolute;
      width: 100%;
      height: 100%;
      top: 0;
      background-image: url(~@/assets/img/home_bg3.png);
      background-repeat: no-repeat;
      background-size: 304px 192px;
      background-position: right bottom;
    }

    .border {
      height: 6px;
      background: linear-gradient(270deg, #8853ff 0%, #5564fe 100%);
      border-radius: 2px 2px 0px 0px;
    }
    .title {
      padding-left: 20px;
      padding-top: 20px;
      padding-bottom: 10px;
      font-size: 20px;
      font-weight: bold;
      color: #17233d;
      line-height: 24px;
    }
    .item {
      padding-left: 20px;
      padding-top: 10px;
      font-size: 14px;
      color: #808695;
    }
    .content {
      font-size: 14px;
      font-family: Helvetica-Bold, Helvetica;
      font-weight: bold;
      color: #515a6e;
      line-height: 24px;
    }
  }
  .bottom {
    margin-top: 16px;
    flex-wrap: wrap;
    .son {
      margin-bottom: 16px;
      width: 210px;
      // height: 210px;
      // background: #ffffff;
      box-shadow: 0px 2px 8px 0px rgba(20, 47, 99, 0.16);
      border-radius: 2px;
      cursor: pointer;
      .img {
        height: 133px;
        background: #ffffff;
        background-image: url(~@/assets/img/icon1.png);
        background-repeat: no-repeat;
        background-size: contain;
        background-position: center;
      }
      .name {
        background: #f8f8f9;
        // padding-top: 1px;
        // padding-bottom: 1px;
        overflow: hidden;
        .tit {
          text-align: center;
          font-size: 14px;
          font-weight: bold;
          color: #17233d;
          line-height: 22px;
          margin: 10px 0;
        }
        .time {
          text-align: center;
          font-size: 14px;
          font-family: Helvetica;
          color: #6e5bfe;
          margin: 10px 0 15px 0;
        }
      }
    }
  }
  .more-tips-box {
    padding-top: 10px;
    .more-tips {
      display: flex;
      padding-bottom: 50px;
      .el-icon-warning-outline {
        color: #50aaf8;
      }
      .more-tips-content {
        margin-left: 5px;
        .tit {
          font-size: 14px;
          font-family: Helvetica;
          color: #17233d;
          font-weight: bold;
        }
        .content {
          font-size: 12px;
          color: #808695;
          margin-top: 5px;
          span {
            color: #6e5bfe;
          }
        }
      }
    }
  }
}
// 响应式设计

@media screen and (max-width: 768px) {
  .detail-container {
    width: 100%;
    padding: 0 6px;
    .top {
      width: 100%;
    }
    .bottom {
      width: 100%;
      padding: 0 20px;
    }
    .more-tips-box {
      .more-tips {
        padding: 0 20px 20px;
      }
    }
  }
}
</style>
